﻿using UnityEngine;
using System.Collections;

public class GUI_scalescript : MonoBehaviour {

	private float resWidth;
	private float resHeight;

	public GUITexture topLeft;
	public GUITexture topRight;
	public GUITexture bottomLeft;
	public GUITexture bottomRight;
	//public GUITexture topMiddle;

	public GUIStyle generalStyle;

	int timeValue = 0;
	// Use this for initialization
	void Start () {


	
	}
	
	// Update is called once per frame
	void Update () {
	
		// Auflösung speichern
		resWidth = Screen.width;
		resHeight = Screen.height;


		// Breite und Höhe der Grafiken speichern
		float topLeftWidth = topLeft.GetScreenRect ().width;
		float topLeftHeight = topLeft.GetScreenRect ().height;
		
		float topRightWidth = topRight.GetScreenRect ().width;
		float topRightHeight = topRight.GetScreenRect ().height;
		
		float bottomLeftWidth = bottomLeft.GetScreenRect ().width;
		float bottomLeftHeight = bottomLeft.GetScreenRect ().height;
		
		float bottomRightWidth = bottomRight.GetScreenRect ().width;
		float bottomRightHeight = bottomRight.GetScreenRect ().height;

		//float topMiddleWidth = topMiddle.GetScreenRect ().width;
		//float topMiddleHeight = topMiddle.GetScreenRect ().height;
		

		// Grafiken positionieren
		Rect timeRect = new Rect( -(resWidth/2) , ((resHeight/2) - topLeftHeight) , topLeftWidth, topLeftHeight);
		topLeft.pixelInset = timeRect;

		Rect healthRect = new Rect( ((resWidth/2) - topRightWidth) , ((resHeight/2) - topRightHeight) , topRightWidth, topRightHeight);
		topRight.pixelInset = healthRect;

		Rect scoreRect = new Rect( -(resWidth/2) , -(resHeight/2) , bottomLeftWidth, bottomLeftHeight);
		bottomLeft.pixelInset = scoreRect;

		Rect ammoRect = new Rect( ((resWidth/2) - bottomRightWidth) , -(resHeight/2), bottomRightWidth, bottomRightHeight);
		bottomRight.pixelInset = ammoRect;

		//Rect titleRect = new Rect( -(topMiddleWidth/2) , ((resHeight/2) - topMiddleHeight), topMiddleWidth, topMiddleHeight);
		//topMiddle.pixelInset = titleRect;

	}

	void OnGUI()
	{
		// Time Wert	
		GUI.TextField (new Rect (220, 0, 60, 20), GetComponent<GameManagerScript>().zeit , generalStyle); 

		// Health Wert
		GUI.TextField (new Rect ((resWidth - 380), 0, 60, 20), GetComponent<GameManagerScript>().playerHealth + "%" , generalStyle);

		// Score Wert
		GUI.TextField (new Rect (400, (resHeight - 150), 60, 20), GetComponent<GameManagerScript>().score + "" , generalStyle);

		// ammo Wert
		GUI.TextField (new Rect ((resWidth - 380), (resHeight - 150), 60, 20), GetComponent<GameManagerScript>().ammo + "" , generalStyle);


	}
}











